package com.tools.web.work.captcha;

import com.tools.common.object.Note;
import com.tools.common.thread.TimePair;
import com.tools.common.thread.Timeunit;

/**
 * 验证码服务接口
 * 返回：0（已过期/不存在）；1（校验成功）；-1（校验错误）；-2（错误次数达到上限）
 * */
@Note("返回：0（已过期/不存在）；1（校验成功）；-1（校验错误）；-2（错误次数达到上限）")
public interface CaptchaService {

    @Note("校验 “比较内容正确” 的验证码逻辑")
    int checkEqualsCaptcha(String key, String sourceCode, boolean ignoreCase);

    @Note("默认忽略大小写，校验 “比较内容正确” 的验证码逻辑")
    int checkEqualsCaptcha(String key, String sourceCode);

    @Note("校验滑动验证码")
    int checkSlideCaptcha(String key, SlideCaptcha source);

    @Note("校验点选验证码")
    int checkClickCaptcha(String key, ClickCaptcha source);

    @Note("设置 “比较内容正确” 的验证码到缓存，并设置过期时间")
    void setEqualsCaptcha(String key, CaptchaResult captchaResult, long expiration, Timeunit timeunit);

    void setEqualsCaptcha(String key, CaptchaResult captchaResult, TimePair expiration);

    @Note("设置滑动验证码到缓存，并设置过期时间")
    void setSlideCaptcha(String key, CaptchaResult captchaResult, long expiration, Timeunit timeunit);

    void setSlideCaptcha(String key, CaptchaResult captchaResult, TimePair expiration);

    @Note("设置点选验证码到缓存，并设置过期时间")
    void setClickSelectCaptcha(String key, CaptchaResult captchaResult, long expiration, Timeunit timeunit);

    void setClickSelectCaptcha(String key, CaptchaResult captchaResult, TimePair expiration);

    CaptchaResult getEqualsCaptcha(String key);

    CaptchaResult getSlideCaptcha(String key);

    CaptchaResult getClickSelectCaptcha(String key);

    void removeCaptcha(String key);

    CaptchaResult newPng();

    CaptchaResult newPng(CaptchaBuilder builder);

    CaptchaResult newGif();

    CaptchaResult newGif(CaptchaBuilder builder);

    CaptchaResult newChinese();

    CaptchaResult newChinese(CaptchaBuilder builder);

    CaptchaResult newChineseGif();

    CaptchaResult newChineseGif(CaptchaBuilder builder);

    CaptchaResult newCalc();

    CaptchaResult newCalc(CaptchaBuilder builder);

    CaptchaResult newSlide(SlideCaptchaBuilder builder);

    CaptchaResult newClickSelect(ClickCaptchaBuilder builder);
}
